package com.shenglaotuan.community.article.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.shenglaotuan.community.tag.entity.Tag;
import com.shenglaotuan.community.tag.mapper.TagMapper;
import com.shenglaotuan.community.user.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
public class ArticleSimpleVO implements Serializable {
    private static final long serialVersionUID = -1543358590365233536L;
    private String id; // 文章id
    private String avatar; // 用户头像
    private String title; // 文章标题
    @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone="GMT+8")
    private Date gmtCreated; // 文章发布时间
    private List<Tag> tags; // 文章标签
    private User user;

    public void findTags(TagMapper tagMapper){
        this.tags = tagMapper.listArticleTags(this.id);
    }
}
